<?php

namespace App\Http\Controllers\Guard\User;

use App\Http\Controllers\Common\GuardController;
use App\Models\User\User;
use Illuminate\Http\Request;

class UserController extends GuardController
{
    public function lst(Request $request) {
        $conditions = $request->input();
        $records = (new User())->getLst($conditions)->paginate($conditions['pageSize'],['*'],'page',$conditions['page']);
        return responseSuccess($records->items(),$records->total());
    }

    public function add(Request $request) {
        $conditions = $request->input();
        $id = $request->input('id',0);
        //dd($conditions);
        $user = User::updateOrCreate(compact('id'),$conditions);
        return responseSuccess($user->toArray());
    }

    public function detail(Request $request) {
        $ids = $request->input('ids','');
        return $this->getRecordByIds(User::class, $ids);
    }

    public function del(Request $request) {
        $ids = $request->input('ids','');
        return $this->delRecords(User::class, $ids);
    }
}
